<template>
  <view class="container">
    <!--      <u-loading-page v-if="isLoading" :loading="isLoading" loading-text="正在检索中..."></u-loading-page>-->
    <u-subsection :list="list" :current="current" :animation="true" @change="sectionChange" bg-color="#ffffff" font-size="15" style="border-bottom: 2rpx solid rgba(250, 250, 250, 1)"></u-subsection>
    <view class="content_list">
      <uni-easyinput placeholder="请输入关键字进行搜索" prefixIcon="search" v-model="searchForm.fileName"> </uni-easyinput>
      <view class="search">
        <uni-data-select class="select" placeholder="专业类型" v-model="searchForm.profession" :localdata="majorTypeList" @change="iconClick"></uni-data-select>
        <uni-data-select class="select" placeholder="文件类型" v-model="searchForm.fileType" :localdata="fileTypeList" @change="iconClick"></uni-data-select>
        <text class="reset" @click="resetFn">重置</text>
        <text @click="batchAllFn">全部</text>
        <!-- <text class="reset" @click="batchOperation">批量操作</text> -->
        <image @click="batchOperation" v-if="!batchStatus" style="width: 35rpx; height: 35rpx" src="../../static/images/nobatch.svg" />
        <image @click="batchOperation" v-else style="width: 35rpx; height: 35rpx" src="../../static/images/batch.svg" />
      </view>
      <view class="header">
        <image src="../../static/images/fileManage/file_title_icon.svg"></image>
        <text>文件内容</text>
      </view>
      <image v-if="processList.length == 0" src="../../static/images/empty.svg" class="empty_img"></image>
      <scroll-view scroll-y="true" v-else :scroll-top="scrollTop" @scrolltolower="scrolltolowerFn" class="screen_list">
        <view class="screen" v-for="(item, index) in processList" :key="index">
          <image @click="checkedFn(item)" v-if="item.checked == false && batchStatus" class="checkbox" src="../../static/images/unchecked.svg"></image>
          <image @click="uncheckedFn(item)" v-if="item.checked == true && batchStatus" class="checkbox" src="../../static/images/checked.svg"></image>
          <!-- <view v-if="batchStatus && item.checked  == undefined" class="checkbox"></view> -->
          <image :src="'../../static/images/fileManage/' + getImage(item.fileFormat)"></image>
          <view @click="handlePreview(item)" class="name-info">
            <view class="name">{{ item.fileName }}</view>
            <view class="info">
              <!-- <text>{{item.author}}</text> -->
              <view>{{ item.uploadTime }}</view>
              <view v-if="current == 0">{{ item.fileVersion }}</view>
              <view>{{ item.versionStatusName }}</view>
              <!-- <text>47.5MB</text> -->
              <view class="round" v-if="current == 0 && item.fileType != 35" :class="item.status == 2 ? 'red' : item.status == 5 ? 'blue' : 'orange'"></view>
              <view v-if="item.approvalTypeName" class="info_last" :class="item.approvalType === 0 ? 'info_last_blue' : 'info_last_red'">
                {{ item.approvalTypeName }}
              </view>
            </view>
          </view>
          <view>
            <!--            <uni-icons type="more-filled" size="20" @click="openMore(index)" class="uni_icons"></uni-icons>-->
            <view :tabindex="index" @click="handleFocus(index)" @focus="handleFocus(index)" @blur="handleBlur(index)" class="handleInput" :class="index === operationIndex ? 'active' : ''"></view>
            <!--                        上传-->
            <view class="operation" ref="operation" v-if="index === operationIndex && current === 0">
              <view class="operation_btn" v-if="item.permissionVo.update" @click="handleUpdate(item)">更新</view>
              <view class="operation_btn" v-if="item.permissionVo.delete" @click="handleDel(item)">删除</view>
              <view class="operation_btn" size="small" v-if="item.fileType === 35" @click="handleOpen(item)">{{ item.expansionStatus == 1 ? '关闭' : '开启' }}</view>
              <view class="operation_btn" v-if="item.permissionVo.submit || item.permissionVo.withdraw" @click="handle(item.permissionVo.submit, item.permissionVo.withdraw, item)">
                {{ item.permissionVo.submit ? "提交" : "撤回" }}
              </view>
              <view class="operation_btn" @click="handleFileInfo(item)">文件信息</view>
              <view class="operation_btn" v-if="item.permissionVo.rejectInfo" @click="rejectInfoFn(item)">驳回原因 </view>
              <!-- <u-button text="编辑" size="small" v-if="item.fileType === 35"
                                    @click="handleEdit(item)"></u-button> -->
            </view>
            <!--                        审核-->
            <view class="operation" ref="operation" v-if="index === operationIndex && current === 1">
              <view class="operation_btn" @click="handlePass(item, 'examine')">通过</view>
              <view class="operation_btn" @click="handleReject(item, 'examine')">驳回</view>
            </view>
            <!--                        批准-->
            <view class="operation" ref="operation" v-if="index === operationIndex && current === 2">
              <view class="operation_btn" @click="handlePass(item, 'approve')">通过</view>
              <view class="operation_btn" @click="handleReject(item, 'approve')">驳回</view>
            </view>
          </view>
        </view>

        <view v-if="loadmore" class="loadMore">—已加载全部—</view>
      </scroll-view>
    </view>
    <u-button class="fileUpload" v-if="current === 0" @click="uploadFn" type="primary" text="文件上传"></u-button>
    <u-button class="fileUpload" v-if="batchStatus" @click="batchFn" type="primary" text="">{{ batchTitle }}</u-button>
    <!-- 文件上传弹框 -->
    <u-popup :show="show" @close="closePopup" :round="10" mode="bottom">
      <view class="upload_popup">
        <u-form :model="uploadForm" :rules="rules" ref="uploadForm" label-width="80px">
          <u-form-item label="专业类型" prop="profession">
            <uni-data-select v-model="uploadForm.profession" :localdata="majorTypeList"></uni-data-select>
          </u-form-item>
          <u-form-item label="文件类型" prop="fileType">
            <uni-data-select v-model="uploadForm.fileType" :localdata="fileTypeList"></uni-data-select>
          </u-form-item>
        </u-form>
        <view class="bottom">
          <u-button text="清空" @click="emptyFn"></u-button>
          <u-button type="primary" text="下一步" @click="sureFn"></u-button>
        </view>
      </view>
    </u-popup>
    <!-- 文件更新 -->
    <u-popup mode="bottom" :show="updateShow" :round="10">
      <view class="container-update">
        <view class="info_item">
          <view class="info_item_label">专业类型：</view>
          <view class="info_item_content">
            <!-- {{updateData.professionName}} -->
            <uni-data-select disabled v-model="updateData.profession" :localdata="majorTypeList"></uni-data-select>
          </view>
        </view>
        <view class="info_item">
          <view class="info_item_label">文件类型：</view>
          <view class="info_item_content">
            <!-- {{updateData.fileTypeName}} -->
            <uni-data-select disabled v-model="updateData.fileType" :localdata="fileTypeList"></uni-data-select>
          </view>
        </view>
        <view class="info_item">
          <view class="info_item_label">文件名称：</view>
          <view class="info_item_content">
            <!-- {{updateData.fileName}} -->
            <uni-easyinput v-model="updateData.fileName" placeholder="请输入文件名称"></uni-easyinput>
          </view>
        </view>
        <view class="info_item">
          <view class="info_item_label">作者姓名：</view>
          <view class="info_item_content">
            <!-- {{updateData.author}} -->
            <uni-easyinput v-model="updateData.author" placeholder="请输入作者姓名"></uni-easyinput>
          </view>
        </view>

        <view class="info_item">
          <view class="info_item_label">上传文件：</view>
          <view class="info_item_content">
            <!-- <u-button @click="handleUpdateData" type="primary">上传</u-button> -->
            <uploadView
              ref="uploadViewRef"
              :btn_title="'上传'"
              :btn_style="{
                background: '#3c9cff',
                color: '#ffffff',
                fontWeight: 300,
                height: '70rpx',
                width: '100%',
                fontFamily: 'Poppins',
                borderRadius: '8rpx',
                fontSize: '32rpx',
                border: '2rpx solid #3c9cff',
              }"
              :upload_url="upload_url"
              :upload_header="{ token: $store.state.user.token }"
              :upload_name="'file'"
              :formats="formats.toString()"
              :size="size"
              :count="1"
              @getFiles="getFiles"
            ></uploadView>
            <view>
              <text class="name">{{ updateProcessList.fileName }}</text>
              <text class="info">
                <text>{{ updateProcessList.uploadTime }}</text>
                <!-- <text>47.5MB</text> -->
              </text>
            </view>
          </view>
        </view>

        <view class="confrim-btn">
          <u-button text="取消" @click="updateShow = false"></u-button>
          <!-- <u-button @click="handleUpdateData" type="primary">上传</u-button> -->
          <u-button type="primary" @click="importFn">确定</u-button>
        </view>
      </view>
    </u-popup>
    <!--        输入对话框-->
    <uni-popup ref="inputDialog" type="dialog">
      <uni-popup-dialog ref="inputClose" mode="input" title="驳 回" value="" placeholder="请输入驳回意见" @confirm="dialogInputConfirm" @close="closeInputConfirm"></uni-popup-dialog>
    </uni-popup>
    <!-- 驳回 -->
    <uni-popup ref="alertDialog" type="dialog">
      <uni-popup-dialog cancelText="关闭" confirmText="确定" title="驳回原因" :content="reasonInfo"></uni-popup-dialog>
    </uni-popup>
    <!--        视频更新-->
    <!-- 模态框 -->
    <u-modal title="更新" content="原文件已入库,如需更新,需对原文件进行升版" showCancelButton :show="updateModel" @cancel="closeModel" @confirm="confirm" ref="uModal" :asyncClose="true"> </u-modal>
  </view>
</template>

<script>
import config from "@/config";
const baseUrl = config.baseUrl;
import uploadView from "../uploadView";
export default {
  components: { uploadView },
  data() {
    return {
      isLoading: false,
      list: ["上传", "待审核", "待批准"],
      loadmore: false,
      show: false,
      updateModel: false,
      current: 0,
      scrollTop: 0,
      batchStatus: false,
      batchTitle: "批量提交",
      searchForm: {
        profession: "",
        fileType: "",
        fileName: "",
      },
      uploadForm: {
        profession: "",
        fileType: "",
      },
      rules: {
        profession: [
          {
            required: true,
            message: "请选择专业类型",
            trigger: "change",
            type: "any",
          },
        ],
        fileType: [
          {
            required: true,
            message: "请选择文件类型",
            trigger: ["change"],
            type: "any",
          },
        ],
      },
      upDateRules: {
        profession: [
          {
            required: true,
            message: "请选择专业类型",
            trigger: "change",
            type: "any",
          },
        ],
        fileType: [
          {
            required: true,
            message: "请选择文件类型",
            trigger: "change",
            type: "any",
          },
        ],
        fileName: [
          {
            required: true,
            message: "请输入文件名称",
            trigger: "blur",
            type: "any",
          },
        ],
        author: [
          {
            required: true,
            message: "请输入作者姓名",
            trigger: "blur",
            type: "any",
          },
        ],
      },
      fileTypeList: [],
      majorTypeList: [],
      operationIndex: -1,
      processList: [],
      pageNumber: 1,
      pageSize: 10,
      totalPage: 0,
      totalSize: 0,
      updateShow: false,
      updateData: {},
      token: "",
      upDateForm: {
        profession: "",
        fileType: "",
        fileName: "",
        author: "",
      },
      updateProcessList: {},
      rejectRow: {},
      rejectType: "",
      id: "",
      resultItem: "",
      reasonInfo: "",
      timeNumber: 3000,
      upload_url: config.baseUrl + "/file/upload",
      formats: [".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", "pdf"],
      size: 1024,
    };
  },

  onPullDownRefresh() {
    this.pageNumber = 1;
    this.pageSize = 10;
    this.totalPage = 0;
    this.totalSize = 0;
    this.getData();
    setTimeout(() => {
      this.loadmore = false;
      uni.stopPullDownRefresh();
    }, 1000);
  },
  // onReachBottom() {
  //   if (this.pageNumber >= this.totalPage) {
  //     this.loadmore = true;
  //     return;
  //   }
  //   this.pageNumber = this.pageNumber + 1;
  //   if (this.pageNumber > this.totalPage) {
  //   } else {
  //     this.getData();
  //   }
  // },
  watch: {
    "searchForm.fileName": {
      handler(newVal, oldVal) {
        this.pageNumber = 1;
        this.pageSize = 10;
        this.totalPage = 0;
        this.totalSize = 0;
        clearTimeout(this.timer);
        this.timer = setTimeout(() => {
          this.getData();
        }, 600);
      },
    },
  },
  mounted() {
    this.fileTypeListFn();
    this.majorTypeListFn();
    this.getData();
    this.token = uni.getStorageSync("token");
    let that = this;
    uni.$on("returnData", function () {
      that.pageNumber = 1;
      that.totalPage = 0;
      that.totalSize = 0;
      that.getData();
    });
  },
  methods: {
    sectionChange(index) {
      this.current = index;
      this.operationIndex = -1;
      this.pageNumber = 1;
      this.totalPage = 0;
      this.totalSize = 0;

      this.resetFn();
    },
    iconClick() {
      this.pageNumber = 1;
      this.totalPage = 0;
      this.totalSize = 0;
      this.processList = [];
      this.getData();
    },
    handleFocus(index) {
      setTimeout(() => {
        this.operationIndex = index;
      }, 50);
    },
    handleBlur(index) {
      setTimeout(() => {
        this.operationIndex = -1;
      }, 50);
    },
    openMore(index) {
      this.operationIndex = index;
      setTimeout(() => {
        this.operationIndex = -1;
      }, this.timeNumber);
    },
    getImage(type) {
      let src = "";
      switch (type) {
        case "xlsx":
        case "xls":
          src = "file_excel.svg";
          break;
        case "docx":
        case "doc":
          src = "file_word.svg";
          break;
        case "mp4":
          src = "file_video.svg";
          break;
        case "ppt":
        case "pptx":
          src = "file_ppt.svg";
          break;
        case "pdf":
          src = "file_pdf.svg";
          break;
        default:
          src = "file_other.svg";
      }
      return src;
    },
    // scroll 触底操作
    scrolltolowerFn(e) {
      console.log("看看滚动条这个事件", e);
      if (this.pageNumber >= this.totalPage) {
        this.loadmore = true;
        return;
      }
      this.pageNumber = this.pageNumber + 1;
      if (this.pageNumber > this.totalPage) {
      } else {
        this.getData();
      }
    },

    // 批量操作
    batchOperation() {
      this.batchStatus = !this.batchStatus;
      if (!this.batchStatus) {
        this.processList.map((item) => {
          item.checked = false;
        });
      }
      if (this.current == 0) {
        this.batchTitle = "批量提交";
      } else if (this.current == 1) {
        this.batchTitle = "批量审核";
      } else {
        this.batchTitle = "批量批准";
      }
    },
    // 全部选中/取消
    batchAllFn() {
      if (this.batchStatus) {
        this.processList.map((item) => {
          if (item.checked == false) {
            item.checked = true;
          }
        });
      }
    },
    // 单个选中操作
    checkedFn(item) {
      item.checked = true;
    },
    // 单个取消选中操作
    uncheckedFn(item) {
      item.checked = false;
    },

    // 批量按钮的操作
    batchFn() {
      let url = "";
      if (this.current == 0) {
        url = "/knowledgeFile/file/batchSubmit";
      } else if (this.current == 1) {
        url = "/knowledgeFile/review/batchPass";
      } else {
        url = "/knowledgeFile/approve/batchPass";
      }
      const batchIds = this.processList
        .filter((item) => item.checked)
        .map((item) => item.id)
        .join(",");

      if (batchIds == "") {
        this.$toast("当前选择为空");
        return;
      }
      console.log(batchIds);

      this.$request({
        url,
        method: "post",
        data: {
          ids: batchIds,
        },
      }).then(({ data }) => {
        this.$toast(`${this.batchTitle}成功`);
        this.resetFn();
      });
    },
    // 查看驳回原因
    rejectInfoFn(item) {
      console.log("ffff", item);
      this.reasonInfo = item.reason;
      this.$refs.alertDialog.open();
    },
    //文件字典
    fileTypeListFn() {
      this.$request({
        url: "/dict/file/list",
        method: "get",
        params: {},
      }).then(({ data }) => {
        data.data.forEach((item) => {
          this.fileTypeList.push({
            value: item.id,
            text: item.name,
            dictType: item.dictType,
            dictCode: item.dictCode,
          });
        });
      });
    },
    //专业字典
    majorTypeListFn() {
      this.$request({
        url: "/dict/major/list",
        method: "GET",
        params: {},
      }).then(({ data }) => {
        data.data.forEach((item) => {
          this.majorTypeList.push({
            value: item.id,
            text: item.name,
            dictCode: item.dictCode,
          });
        });
      });
    },
    getData() {
      let that = this;
      that.isLoading = true;
      let url = "";
      if (this.current === 0) {
        url = "/knowledgeFile/list";
      } else if (this.current === 1) {
        url = "/knowledgeFile/review/list";
      } else {
        url = "/knowledgeFile/approve/list";
      }
      this.$request({
        url: url,
        method: "GET",
        params: {
          ...this.searchForm,
          pageNumber: this.pageNumber,
          pageSize: this.pageSize,
        },
      })
        .then(({ data }) => {
          that.scrollTop = 0;
          that.isLoading = false;
          if (this.pageNumber === 1) {
            this.processList = [];
          }
          this.totalPage = data.totalPage;
          this.totalSize = data.totalSize;
          if (data.data) {
            data.data.map((item) => {
              if ((item.folderType == 0 && this.current == 0 && item.permissionVo && item.permissionVo.submit) || this.current == 1 || this.current == 2) {
                item.checked = false;
              }
            });
            this.processList = this.processList.concat(data.data);
          }

          // this.$toast("加载中...");
        })
        .catch(() => {
          that.isLoading = false;
        });
    },
    handle(submit, withdraw, row) {
      this.operationIndex = -1;
      let that = this;
      if (submit) {
        //提交
        uni.showModal({
          title: "提示",
          content: "确认提交该数据吗？",
          success: function (res) {
            if (res.confirm) {
              that
                .$request({
                  url: "/knowledgeFile/file/submit",
                  method: "post",
                  data: {
                    id: row.id,
                  },
                })
                .then(({ data }) => {
                  that.$modal.loading("提交成功！");
                  setTimeout(() => {
                    that.$modal.closeLoading();
                  }, 1000);
                  that.pageNumber = 1;
                  that.getData();
                });
            } else if (res.cancel) {
              console.log("用户点击取消");
            }
          },
        });
      } else if (withdraw) {
        //撤回
        uni.showModal({
          title: "提示",
          content: "确认撤回该数据吗？",
          success: function (res) {
            if (res.confirm) {
              that
                .$request({
                  url: "/knowledgeFile/file/withdraw",
                  method: "post",
                  data: {
                    id: row.id,
                  },
                })
                .then(({ data }) => {
                  that.$modal.loading("撤回成功！");
                  setTimeout(() => {
                    that.$modal.closeLoading();
                  }, 1000);
                  that.pageNumber = 1;
                  that.getData();
                });
            } else if (res.cancel) {
              console.log("用户点击取消");
            }
          },
        });
      }
    },
    handleDel(row) {
      let that = this;
      this.operationIndex = -1;
      uni.showModal({
        title: "提示",
        content: "确认删除该数据吗？",
        success: function (res) {
          if (res.confirm) {
            that
              .$request({
                url: "/knowledgeFile/file/delete",
                method: "post",
                data: {
                  id: row.id,
                },
              })
              .then(({ data }) => {
                that.$modal.loading("删除成功！");
                setTimeout(() => {
                  that.$modal.closeLoading();
                });
                that.pageNumber = 1;
                that.getData();
              });
          } else if (res.cancel) {
            console.log("用户点击取消");
          }
        },
      });
    },
    handleOpen(row) {
      let that = this;
      this.operationIndex = -1;
      uni.showModal({
        title: "提示",
        content: `确认${ row.expansionStatus == 1 ? '关闭' : '开启' }该数据吗？`,
        success: function (res) {
          if (res.confirm) {
            that
              .$request({
                url: "/knowledgeFile/file/switchVideoFolder",
                method: "post",
                data: {
                  id: row.id,
                  expansionStatus: row.expansionStatus == 1 ? 0 : 1,
                },
              })
              .then(({ data }) => {
                that.$modal.loading("操作成功！");
                setTimeout(() => {
                  that.$modal.closeLoading();
                });
                that.pageNumber = 1;
                that.getData();
              });
          } else if (res.cancel) {
            console.log("用户点击取消");
          }
        },
      });
    },
    getFiles(list) {
      console.log("父级附件列表", list);
      this.updateProcessList = list;
    },
    handleFileInfo(item) {
      this.operationIndex = -1;
      this.$tab.navigateTo(`/pages/fileManage/fileInfo?item=${encodeURIComponent(JSON.stringify(item))}`);
    },

    resetFn() {
      this.searchForm.profession = "";
      this.searchForm.fileType = "";
      this.searchForm.fileName = "";

      this.batchStatus = false;
      this.iconClick();
    },
    handlePass(row, type) {
      this.operationIndex = -1;
      let that = this;
      if (type === "examine") {
        that
          .$request({
            url: "/knowledgeFile/review/pass",
            method: "post",
            data: {
              id: row.id,
            },
          })
          .then(({ data }) => {
            that.$modal.loading("已审核通过！");
            setTimeout(() => {
              that.$modal.closeLoading();
            });
            that.pageNumber = 1;
            that.getData();
          });
      } else {
        that
          .$request({
            url: "/knowledgeFile/approve/pass",
            method: "post",
            data: {
              id: row.id,
            },
          })
          .then(({ data }) => {
            that.$modal.loading("已批准通过！");
            setTimeout(() => {
              that.$modal.closeLoading();
            });
            that.pageNumber = 1;
            that.getData();
          });
      }
    },
    handleReject(row, type) {
      console.log(row, type, "row, type");
      this.operationIndex = -1;
      this.rejectRow = row;
      this.rejectType = type;
      this.$refs.inputDialog.open();
    },
    closeInputConfirm() {
      this.$refs.inputDialog.close();
    },
    dialogInputConfirm(value) {
      if (value.length >= 50) {
        this.$toast("驳回原因不能超过50字");
        return;
      }
      let that = this;
      if (this.rejectType === "examine") {
        that
          .$request({
            url: "/knowledgeFile/review/turnDown",
            method: "post",
            data: {
              id: this.rejectRow.id,
              reason: value,
            },
          })
          .then(({ data }) => {
            that.$refs.inputDialog.close();
            that.$modal.loading("驳回成功！");
            setTimeout(() => {
              that.$modal.closeLoading();
            });
            that.pageNumber = 1;
            that.getData();
          });
      } else {
        that
          .$request({
            url: "/knowledgeFile/approve/turnDown",
            method: "post",
            data: {
              id: this.rejectRow.id,
              reason: value,
            },
          })
          .then(({ data }) => {
            that.$refs.inputDialog.close();
            that.$modal.loading("驳回成功！");
            setTimeout(() => {
              that.$modal.closeLoading();
            });
            that.pageNumber = 1;
            that.getData();
          });
      }
    },
    uploadFn() {
      this.show = true;
    },
    closePopup() {
      this.uploadForm.profession = "";
      this.uploadForm.fileType = "";
      this.show = false;
    },
    emptyFn() {
      this.uploadForm.profession = "";
      this.uploadForm.fileType = "";
      this.show = false;
    },
    sureFn() {
      let that = this;
      if ((this.uploadForm.profession == "")) {
        this.$toast("请选择专业类型");
        return;
      }
      if ((this.uploadForm.fileType == "")) {
        this.$toast("请选择专业类型");
        return;
      }
      that.$refs.uploadForm.validate().then((res) => {
        that.show = false;
        // that.uploadForm.fileType
        let tempArray = that.fileTypeList.filter((item) => item.value === that.uploadForm.fileType);
        console.log("查看该文件信息", tempArray);
        const path = tempArray[0].dictType === "E1" ? "videoUpload" : "fileUpload";
        uni.navigateTo({
          url: path + `?uploadForm=` + encodeURIComponent(JSON.stringify(that.uploadForm)),
        });
        this.uploadForm.profession = "";
        this.uploadForm.fileType = "";
      });
    },
    handleEdit(item) {
      this.operationIndex = -1;
      console.log(item, "编辑");
      this.$tab.navigateTo(`/pages/fileManage/videoUpload?uploadForm=${encodeURIComponent(JSON.stringify(item))}`);
    },
    handleUpdate(row) {
      this.operationIndex = -1;
      this.resultItem = row;
      if (row && row.status == 5) {
        // 模态框提示
        this.updateModel = true;
        return;
      } // 判断是文件需要进入到更新页面
      if (this.resultItem.fileType === 35) {
        this.operationIndex = -1;
        // 	this.$tab.navigateTo(`/pages/fileManage/updateVideo?uploadForm=${encodeURIComponent(JSON.stringify({
        //     ...this.resultItem,
        //     methods: 'videoUpdate'
        // }))}`)
        this.$tab.navigateTo(
          `/pages/fileManage/videoUpload?uploadForm=${encodeURIComponent(
            JSON.stringify({
              ...this.resultItem,
              methods: "videoUpdate",
            })
          )}`
        );
        return true;
      }
      this.updateData = JSON.parse(JSON.stringify(row));
      this.id = this.resultItem.id;
      this.updateShow = true;
    },
    closeModel() {
      this.updateModel = false;
      console.log("4444");
    },
    confirm() {
      this.operationIndex = -1;
      this.id = this.resultItem.id;
      this.updateData = JSON.parse(JSON.stringify(this.resultItem));
      this.updateModel = false;
      this.updateShow = true;
    },
    handleUpdateData() {
      let that = this;
      uni.chooseFile({
        count: 1, //默认100
        extension: [".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", "pdf"],
        success: function (res) {
          res.tempFilePaths.forEach((item) => {
            uni.uploadFile({
              url: config.baseUrl + "/file/upload",
              header: {
                token: that.token,
              },
              filePath: item,
              name: "file",
              success: (uploadFileRes) => {
                let tempData = JSON.parse(uploadFileRes.data);

                console.log("查看上传文件", tempData);
                that.updateProcessList = [];
                that.updateProcessList = tempData.data;
                // that.importFn(that.processList)
              },
              fail: (uploadFileError) => {
                // 处理上传失败的错误
              },
            });
          });
        },
      });
    },

    importFn() {
      console.log("ffff", this.updateProcessList);
      this.$request({
        url: "/knowledgeFile/file/update",
        method: "post",
        data: {
          author: this.updateData.author,
          fileId: this.updateProcessList.id,
          fileName: this.updateData.fileName,
          fileType: this.updateData.fileType,
          profession: this.updateData.profession,
          id: this.id,
        },
      }).then(({ data }) => {
        this.$toast("更新成功");
        this.updateShow = false;
        this.pageNumber = 1;
        this.getData();
      });
    },
    handlePreview(item) {
      console.log(item, "进入详情页");
      if (item.fileType == 35 && this.current == 0) {
        this.$tab.navigateTo(
          `/pages/fileManage/updateVideo?uploadForm=${encodeURIComponent(
            JSON.stringify({
              ...item,
              methods: "videoUpdate",
            })
          )}`
        );
        return;
      }

      this.$request({
        url: "/knowledgeData/preview",
        method: "get",
        params: {
          id: item.id,
        },
      }).then(({ data }) => {
        console.log(data, "fff");
        // return''
        if (data.readAuthority == false) {
          this.$toast(data.message);
          return;
        }

        console.log(item, "预览文件");
        const search = false;
        if (item.fileType == 35) {
          if (["ppt", "pptx", "pdf", "doc", "docx"].includes(item.fileFormat)) {
            uni.navigateTo({
              url: `/pages/previewOriginal?info=` + encodeURIComponent(JSON.stringify(item)) + `&search=` + search + `&showCollects=false`,
            });
          } else {
            uni.navigateTo({
              url: `/pages/player?info=` + encodeURIComponent(JSON.stringify(item)) + `&search=` + search + `&showCollects=false&downloadUrl=` + encodeURIComponent(JSON.stringify(data.downloadUrl)),
            });
          }
          return
        }
        if (item.fileType == 38) {
          uni.navigateTo({
            url: `/pages/player?info=` + encodeURIComponent(JSON.stringify(item)) + `&search=` + search + `&showCollects=false&downloadUrl=` + encodeURIComponent(JSON.stringify(data.downloadUrl)),
          });
        }
        // 指导书需要跳转的地方
        else if (Number(item.fileType) === 34) {
          uni.navigateTo({
            url: `/pages/previewOriginal?info=` + encodeURIComponent(JSON.stringify(item)) + `&search=` + search + `&showCollects=false`,
          });
        } else if (item.fileType == 38) {
          uni.navigateTo({
            url: `/pages/player?info=` + encodeURIComponent(JSON.stringify(item)) + `&search=` + search + `&showCollects=false&downloadUrl=` + encodeURIComponent(JSON.stringify(data.downloadUrl)),
          });
        } else if (item.fileType == 32) {
          uni.navigateTo({
            url: `/pages/previewOriginal?info=` + encodeURIComponent(JSON.stringify(item)) + `&search=` + search + `&showCollects=false`,
          });
        } else if (item.fileType == 33) {
          uni.navigateTo({
            url: `/pages/previewOriginal?info=` + encodeURIComponent(JSON.stringify(item)) + `&search=` + search + `&showCollects=false`,
          });
        } else {
          uni.navigateTo({
            url: `/pages/previewOriginal?info=` + encodeURIComponent(JSON.stringify(item)) + `&search=` + search + `&showCollects=false`,
          });
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  ::v-deep {
    .u-subsection__item__text {
      font-family: Arial;
      font-size: 30rpx;
    }
    .is-input-border {
      border: 1px solid #0084ff !important;
      border-radius: 120rpx;
    }

    .uni-easyinput__placeholder-class,
    .uni-input-input {
      font-family: Arial;
      font-size: 30rpx;
    }
    .uni-easyinput {
      padding: 42rpx 0 20rpx;
    }
  }
}
.content_list {
  // height: auto;
  // overflow-y: auto;
  padding: 0 30rpx;
  .search {
    width: 100%;
    display: flex;
    padding: 20rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    min-height: 78rpx;
    border-radius: 16rpx;
    background: #ffffff;
    ::v-deep .uni-select__input-box {
      max-width: 240rpx;
    }
    ::v-deep.uni-stat__select {
      flex: none;
      width: auto;
    }

    ::v-deep.uni-select,
    ::v-deep.uni-select__input-placeholder {
      font-family: Source Han Sans;
      font-size: 30rpx;
      font-weight: 500;
      border: none;
    }

    .reset {
      font-family: Arial;
      color: #02a7f0;
      font-weight: 500;
      margin-left: 30rpx;
      min-width: 66rpx;
    }
  }

  .header {
    width: 100%;
    font-family: Source Han Sans;
    font-size: 32rpx;
    font-weight: 500;
    color: #1c2126;
    margin: 40rpx 0 22rpx;
    display: flex;
    image {
      width: 44rpx;
      height: 44rpx;
      margin-right: 20rpx;
    }
  }
  .screen_list {
    height: 55vh;
    border-radius: 16rpx;
    background: #ffffff;
    margin-bottom: 154rpx;
    .screen {
      padding: 30rpx 28rpx;
      display: grid;
      grid-template-columns: 44rpx 1fr 32rpx;
      grid-column-gap: 30rpx;
      align-items: start;
      position: relative;
      display: flex;
      .checkbox {
        align-self: center;
      }
      & + .screen:before {
        content: "";
        height: 1rpx;
        position: absolute;
        left: 20rpx;
        top: 0;
        right: 20rpx;
        border-top: 1rpx solid #e4e4e4;
      }

      image {
        width: 44rpx;
        height: 40rpx;
      }

      .name-info {
        width: 100%;
        display: flex;
        flex-direction: column;
        z-index: 99;

        .name {
          font-size: 30rpx;
          font-weight: 500;
          margin-bottom: 10rpx;
          font-family: 思源黑体;
          color: #1c2126;
          word-break: break-all;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3;
          overflow: hidden;
          text-overflow: ellipsis;
          text-align: justify;
        }
        .info_last {
          margin-left: 20rpx;
          height: 40rpx;
          width: 144rpx;
          border-radius: 12rpx;
          font-family: Source Han Sans;
          font-size: 24rpx;
          font-weight: 500;
          text-align: center;
          line-height: 40rpx;
          &.info_last_red {
            background: #ffece8;
            color: #f53f3f;
          }
          &.info_last_blue {
            background: #e8f8ff;
            color: #0084ff;
          }
        }
      }
      .uni_icons {
        &:hover,
        &:active {
          color: #0084ff !important;
        }
      }
      .operation {
        width: 172rpx !important;
        position: absolute;
        margin-right: 20rpx;
        right: -10rpx;
        z-index: 999999;
        background: #ffffff;
        box-shadow: 0 2rpx 8rpx 0px rgba(170, 190, 206, 0.4);

        .operation_btn {
          width: 172rpx;
          height: 60rpx;
          line-height: 60rpx;
          text-align: center;
          font-family: 思源黑体;
          font-size: 30rpx;
          color: #1c2126;
          &:hover,
          &:active {
            color: #0084ff;
            background: #f4f6f9;
          }
        }
      }

      .info {
        font-size: 24rpx;
        color: #4c5a67;
        font-family: 思源黑体;
        display: flex;
        align-items: center;

        view:nth-child(2) {
          margin: 0 24rpx;
        }

        view:nth-child(3) {
          margin-right: 24rpx;
        }

        .round {
          width: 20rpx;
          height: 20rpx;
          display: inline-block;
        }

        .orange {
          background: #f9d548;
          box-shadow: 0px 0px 4px 0px rgba(249, 213, 72, 0.4);
        }

        .red {
          background: #f53f3f;
          box-shadow: 0px 0px 4px 0px rgba(245, 63, 63, 0.4);
        }

        .blue {
          background: #0084ff;
          box-shadow: 0px 0px 4px 0px rgba(0, 132, 255, 0.4);
        }
      }
    }
  }
}

.fileUpload {
  position: fixed;
  bottom: 110rpx;
  width: calc(100% - 40rpx);
  margin-left: 20rpx;
  z-index: 100;
  font-size: 32rpx;
  font-family: Poppins;
  font-weight: 600;
  height: 100rpx;
  border-radius: 16rpx;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  background: #0084ff;
}

.upload_popup {
  height: 700rpx;
  padding: 40rpx;

  // display: flex;
  // background: red;
  .upload_type {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100rpx;
    gap: 30rpx;
  }
  ::v-deep {
    .u-form-item__body__left__content {
      font-family: 思源黑体;
      font-size: 30rpx;
    }
    .uni-select__input-placeholder,
    .uni-select__selector-item,
    .uni-select__input-text {
      font-family: Arial;
      font-size: 30rpx;
      color: #4c5a67;
    }
  }
  .bottom {
    width: 100%;
    padding: 0 50rpx;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-column-gap: 30rpx;
    position: absolute;
    bottom: 40rpx;
    left: 0;
    ::v-deep.u-button {
      width: 100%;
      height: 80rpx;
      border-radius: 16rpx;
      font-family: Poppins;
      font-size: 32rpx;
      font-weight: 600;
      border-width: 1rpx;
    }
  }
}

.container-update {
  padding: 20rpx 50rpx;
  height: max-content;

  .info_item {
    display: flex;
    // height: 60rpx;
    line-height: 60rpx;
    margin: 20rpx 0;

    .info_item_label {
      width: 160rpx;
    }

    .info_item_content {
      flex: 1;
    }
  }

  .confrim-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;

    .u-button {
      width: 40%;
    }
  }
}

.loadMore {
  color: #b5b5b5;
  line-height: 2;
  font-size: 12px;
  text-align: center;
}
</style>
<style lang="scss">
textarea.uni-modal__textarea {
  font-size: 32rpx !important;
}
</style>
